package com.chenfei.poi.service.impl;

import com.chenfei.poi.domain.DeviceCirculation;
import com.chenfei.poi.mapper.DeviceCirculationMapper;
import com.chenfei.poi.request.device.DeviceReq;
import com.chenfei.poi.response.device.DeviceDetailResp;
import com.chenfei.poi.response.device.DeviceResp;
import com.chenfei.poi.service.DeviceService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author chenfei
 * @description
 * @since 2018/2/5
 */
@Service
public class DeviceServiceImpl implements DeviceService {

    @Autowired
    PageHelper pageHelper;
    @Autowired
    DeviceCirculationMapper deviceCirculationMapper;

    @Override
    public int addDevices(List<DeviceCirculation> deviceCirculations) {
        return deviceCirculationMapper.insertDeviceCirculations(deviceCirculations);
    }

    @Override
    public DeviceResp index(DeviceReq deviceReq) {
        DeviceResp deviceResp = new DeviceResp();
        deviceResp.setTotal(deviceCirculationMapper.selectTotalCount());
        PageHelper.startPage(deviceReq.getCurrentPage(), deviceReq.getPageSize());
        deviceResp.setList(deviceCirculationMapper.selectDeviceCirculations(deviceReq));
        return deviceResp;
    }

    @Override
    public List<DeviceDetailResp> list(DeviceReq deviceReq) {
        PageHelper.startPage(deviceReq.getCurrentPage(), deviceReq.getPageSize());
        return deviceCirculationMapper.selectDeviceCirculations(deviceReq);
    }

    @Override
    public List<DeviceDetailResp> listNotPage(DeviceReq deviceReq) {
        return deviceCirculationMapper.selectDeviceCirculations(deviceReq);
    }


}
